/**
 * @Description  : 
 * @FilePath     : /ns_library/include/drv_i2c.h
 * @Author       : xiongjinqi
 * @Date         : 2024-12-10 13:22:23
 * @Version      : 0.0.1
 * @LastEditors  : xiongjinqi
 * @LastEditTime : 2024-12-10 13:25:38
 * @Copyright    : Copyright (c) 2024 by XJQ, All Rights Reserved. 
**/
#ifndef __DRV_I2C_H_
#define __DRV_I2C_H_

#include "types.h"
#include "i2c/i2c_core.h"


#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


static inline int i2c_master_recv(const struct i2c_client *client,
                  char *buf, int count)
{
    return i2c_transfer_buffer_flags(client, buf, count, I2C_M_RD);
};

static inline int i2c_master_recv_dmasafe(const struct i2c_client *client,
                      char *buf, int count)
{
    return i2c_transfer_buffer_flags(client, buf, count,
                     I2C_M_RD | I2C_M_DMA_SAFE);
};

static inline int i2c_master_send(const struct i2c_client *client,
                  const char *buf, int count)
{
    return i2c_transfer_buffer_flags(client, (char *)buf, count, 0);
};

static inline int i2c_master_send_dmasafe(const struct i2c_client *client,
                      const char *buf, int count)
{
    return i2c_transfer_buffer_flags(client, (char *)buf, count,
                     I2C_M_DMA_SAFE);
};

int i2c_add_adapter(struct i2c_adapter *adapter);
void i2c_del_adapter(struct i2c_adapter *adap);

int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
int i2c_bus_register(const char* cname, 
                            struct i2c_client *client, 
                            struct i2c_adapter *adap);
int i2c_bus_unregister(const char *cname);



#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DRV_I2C_H_ */
